#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<math.h>
int judge(int i) {
	int sum = 0;
	int j = 0;
	int k;
	for (k = i; k > 0; k/=10) {
		j++;
	}
	k = i;
	while (k > 0) {
		sum += pow(k % 10, j);
		k /= 10;
	}
	if (sum == i) {
		return 1;
	}
	else {
		return 0;
	}
}

int main()
{
	int n = 0;
	scanf("%d", &n);
	int m = 1;
	while (m<=n) {
		if (judge(m) == 1) {
			printf("%d\n", m);
		}
		m++;
	}
	return 0;
}